#ifndef WRAPEDGEITERATOR_H_
#define WRAPEDGEITERATOR_H_

#include "graph_support/IGraph.h"
#include "graph_support/Graph.h"

#include "graph_support/utils/RTTIStorage.h"


namespace GRAPH_SUPPORT_NS
{

namespace impls
{

template< typename SubIterT, typename GraphT > // TODO: common style of Sub??
class WrapEdgeIterator : public IGraph::IEdgeIterator
{
private:
	typedef GraphT Graph;
	typedef typename Graph::EdgeAttributes EdgeAttributes;
	typedef SubIterT EdgeIterator;
	typedef typename IGraph::EdgeAttributesImpl< EdgeAttributes >::Attributes IEdgeAttributesImpl;

public:
	// TODO:  TheGraph & gr -> TheGraph * gr
	WrapEdgeIterator( Graph & gr, const EdgeIterator & beg, const EdgeIterator & end )
		: gr( & gr )
		, cur( beg )
		, end( end )
	{
	}

public:
	virtual bool notFinished()
	{
		return cur != end;
	}

	virtual void next()
	{
		++cur;
	}

	virtual size_t getDestination()
	{
		return ( * cur )->endId();
	}

	virtual IGraph::IEdgeAttributesPtr getEdgeAttributes()
	{
		return IGraph::IEdgeAttributesPtr( new IEdgeAttributesImpl( & ( * cur )->getAttributes() ) );
	}

private:
	Graph * gr;
	EdgeIterator cur;
	EdgeIterator end;
};

}

}

#endif /* WRAPEDGEITERATOR_H_ */
